diff --git a/sbws/lib/relayprioritizer.py b/sbws/lib/relayprioritizer.py
index bb64b06e47b12fd466760b387d3ce6f179113c5f..4932ea89407c8e66cc38d87f2351093e47554c35 100644
--- a/sbws/lib/relayprioritizer.py
+++ b/sbws/lib/relayprioritizer.py
@@ -143,7 +143,9 @@ class RelayPrioritizer:
         # Increment the number of times ``best_priority`` has been run.
         self.increment_priority_lists()
         # Increment the number of relays that have been "prioritized".
-        self.increment_priority_relays(upper_limit)
+        # Because in a small testing network the upper limit could be smaller
+        # than the number of relays in the network, use the length of the list.
+        self.increment_priority_relays(len(relays[0:upper_limit]))
         for relay in relays[0:upper_limit]:
             log.debug('Returning next relay %s with priority %f',
                       relay.nickname, relay.priority)