diff --git a/net/prefix.go b/net/prefix.go
index cb4d525e8dd70e06899f14879122e41e13ccfaa8..126090fa3713f4331c80c3420dca969e9afe68d5 100644
--- a/net/prefix.go
+++ b/net/prefix.go
@@ -69,7 +69,7 @@ func (pfx Prefix) Contains(x Prefix) bool {
 		return false
 	}
 
-	mask := (uint32(1) << (32 - pfx.pfxlen))
+	mask := uint32((math.MaxUint32 << (32 - pfx.pfxlen)))
 	return (pfx.addr & mask) == (x.addr & mask)
 }
 
diff --git a/net/prefix_test.go b/net/prefix_test.go
index 5f5d4f032cc6e7c86dc6ca8368900fe5d21f0ac5..9ab908bca278be9a526c2570c9bbdc07a8d017a0 100644
--- a/net/prefix_test.go
+++ b/net/prefix_test.go
@@ -179,6 +179,18 @@ func TestContains(t *testing.T) {
 			},
 			expected: false,
 		},
+		{
+			name: "Test 7",
+			a: Prefix{
+				addr:   strAddr("169.0.0.0"),
+				pfxlen: 25,
+			},
+			b: Prefix{
+				addr:   strAddr("169.1.1.0"),
+				pfxlen: 26,
+			},
+			expected: false,
+		},
 	}
 
 	for _, test := range tests {
@@ -332,3 +344,8 @@ func TestStrToAddr(t *testing.T) {
 		assert.Equal(t, test.expected, res)
 	}
 }
+
+func strAddr(s string) uint32 {
+	ret, _ := StrToAddr(s)
+	return ret
+}
diff --git a/protocols/bgp/server/fsm_established.go b/protocols/bgp/server/fsm_established.go
index 2f73297cd299837c9c5425c546bf03d751b50e16..80ff7fa7990493186924f8c35f1a90deb0c93e5b 100644
--- a/protocols/bgp/server/fsm_established.go
+++ b/protocols/bgp/server/fsm_established.go
@@ -234,7 +234,6 @@ func (s *establishedState) updates(u *packet.BGPUpdate) {
 				path.BGPPath.LargeCommunities = pa.LargeCommunityString()
 			}
 		}
-		fmt.Printf("Adding path for pfx: %s\n", pfx.String())
 		s.fsm.adjRIBIn.AddPath(pfx, path)
 	}
 }
diff --git a/protocols/bgp/server/fsm_test.go b/protocols/bgp/server/fsm_test.go
index 7b4579bed6bc771063831a277f48f4dd9261b9ea..7c0646f1617d957e8ed439989415c5fccd2d3e50 100644
--- a/protocols/bgp/server/fsm_test.go
+++ b/protocols/bgp/server/fsm_test.go
@@ -1,7 +1,6 @@
 package server
 
 import (
-	"fmt"
 	"sync"
 	"testing"
 	"time"
@@ -13,7 +12,8 @@ import (
 	"github.com/bio-routing/bio-rd/routingtable/locRIB"
 )
 
-func TestFSM(t *testing.T) {
+// TestFSM100Updates emulates receiving 100 BGP updates and withdraws. Checks route counts.
+func TestFSM100Updates2(t *testing.T) {
 	fsmA := newFSM2(&peer{
 		addr:         net.ParseIP("169.254.100.100"),
 		rib:          locRIB.New(),
@@ -54,9 +54,12 @@ func TestFSM(t *testing.T) {
 	}()
 
 	for i := uint8(0); i < 255; i++ {
+		a := i % 10
+		b := i % 8
+
 		update := []byte{
 			255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
-			0, 53,
+			0, 54,
 			2,
 			0, 0,
 			0, 26,
@@ -81,41 +84,40 @@ func TestFSM(t *testing.T) {
 			3,              // Attribute Type code (Next Hop)
 			4,              // Length
 			10, 11, 12, 13, // Next Hop
-			24, 169, 254, i,
+			b + 25, 169, a, i, 0,
 		}
 
 		fsmA.msgRecvCh <- update
 	}
 
+	time.Sleep(time.Second)
 	ribRouteCount := fsmA.rib.RouteCount()
 	if ribRouteCount != 255 {
 		t.Errorf("Unexpected route count in LocRIB: %d", ribRouteCount)
 	}
 
-	fmt.Printf("Route count in RIB: %d\n", fsmA.rib.RouteCount())
-
 	for i := uint8(0); i < 255; i++ {
+		a := i % 10
+		b := i % 8
+
 		update := []byte{
 			255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
-			0, 27,
+			0, 28,
 			2,
-			0, 4,
-			24, 169, 254, i,
+			0, 5,
+			b + 25, 169, a, i, 0,
 			0, 0,
 		}
 		fsmA.msgRecvCh <- update
+		ribRouteCount = fsmA.rib.RouteCount()
 	}
-	time.Sleep(time.Second)
+	time.Sleep(time.Second * 1)
 
 	ribRouteCount = fsmA.rib.RouteCount()
 	if ribRouteCount != 0 {
 		t.Errorf("Unexpected route count in LocRIB: %d", ribRouteCount)
 	}
 
-	fmt.Printf("Route count in RIB: %d\n", fsmA.rib.RouteCount())
-
-	fmt.Printf("Stopping FSM\n")
 	fsmA.eventCh <- ManualStop
-	fmt.Printf("WAITING\n")
 	wg.Wait()
 }
diff --git a/routingtable/trie.go b/routingtable/trie.go
index a1be18251c82b019d3967cb239135ca24ac631fa..5e719f086ec9b60d1466775d495a34cf35159eed 100644
--- a/routingtable/trie.go
+++ b/routingtable/trie.go
@@ -137,6 +137,7 @@ func (n *node) addPath(pfx net.Prefix, p *route.Path) (*node, bool) {
 
 	// pfx is a subnet of this node
 	b := getBitUint32(pfx.Addr(), n.route.Pfxlen()+1)
+
 	if !b {
 		return n.insertLow(pfx, p, currentPfx.Pfxlen())
 	}
@@ -225,5 +226,6 @@ func (n *node) dump(res []*route.Route) []*route.Route {
 
 	res = n.l.dump(res)
 	res = n.h.dump(res)
+
 	return res
 }