diff --git a/test/Spec.hs b/test/Spec.hs
index 0119261c7fbd0412ae0ff1b631a07d9f7e020584..11671d6be1cd2bdb8707526d92a73c4c2cc20ec1 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -82,6 +82,16 @@ simpleAnnouncement nick furl =
         }
     )
 
+{- | Build a lookup function that can look up any server in the given list
+ from its announcement.
+-}
+simpleLookup :: Applicative f => [(T.Text, b)] -> StorageServerAnnouncement -> f (Either LookupError b)
+simpleLookup [] _ = pure . Left $ AnnouncementStructureUnmatched
+simpleLookup ((furl, server) : ss) ann@StorageServerAnnouncement{storageServerAnnouncementFURL} =
+    if Just furl == storageServerAnnouncementFURL
+        then pure . pure $ server
+        else simpleLookup ss ann
+
 tests :: TestTree
 tests =
     testGroup
@@ -144,10 +154,7 @@ tests =
             storageServerWrite server (storageIndex . verifier $ cap) 1 0 "Hello world"
 
             -- Make the server reachable.
-            let openServer StorageServerAnnouncement{storageServerAnnouncementFURL} =
-                    if storageServerAnnouncementFURL == Just "somewhere"
-                        then pure . pure $ server
-                        else pure . Left $ AnnouncementStructureUnmatched
+            let openServer = simpleLookup [("somewhere", server)]
 
             -- Try to download the cap which requires three shares to reconstruct.
             result <- liftIO $ download anns cap openServer
@@ -178,11 +185,7 @@ tests =
             storageServerWrite elsewhere idx 0 offset "Hello world"
 
             -- Make the server reachable.
-            let openServer StorageServerAnnouncement{storageServerAnnouncementFURL} =
-                    case storageServerAnnouncementFURL of
-                        Just "somewhere" -> pure . pure $ somewhere
-                        Just "elsewhere" -> pure . pure $ elsewhere
-                        _ -> pure . Left $ AnnouncementStructureUnmatched
+            let openServer = simpleLookup [("somewhere", somewhere), ("elsewhere", elsewhere)]
 
             -- Try to download the cap which requires three shares to reconstruct.
             result <- liftIO $ download anns cap openServer
@@ -197,10 +200,7 @@ tests =
             server <- breakGetBuckets BespokeFailure <$> memoryStorageServer
 
             -- Make the server reachable.
-            let openServer StorageServerAnnouncement{storageServerAnnouncementFURL} =
-                    if storageServerAnnouncementFURL == Just "somewhere"
-                        then pure . pure $ server
-                        else pure . Left $ AnnouncementStructureUnmatched
+            let openServer = simpleLookup [("somewhere", server)]
 
             -- Something to pretend to try to download
             let cap = trivialCap 3 13
@@ -229,10 +229,7 @@ tests =
             storageServerWrite server idx 2 offset "Hello world"
 
             -- Make the server reachable.
-            let openServer StorageServerAnnouncement{storageServerAnnouncementFURL} =
-                    if storageServerAnnouncementFURL == Just "somewhere"
-                        then pure . pure $ server
-                        else pure . Left $ AnnouncementStructureUnmatched
+            let openServer = simpleLookup [("somewhere", server)]
 
             -- Try to download the cap which requires three shares to reconstruct.