         }
 
         let user = User(id: 4, name: "Matt")
-        
+
         buildServerTest(router, timeout: 30)
             .request("post", path: "/userMiddleware", data: user, headers: ["TestHeader": "Hello"])
             .hasStatus(.created)
             .hasContentType(withPrefix: "application/json")
             .hasData(user)
-            
+
             .request("post", path: "/userMiddleware", data: user)
             .hasStatus(.badRequest)
             .hasNoData()
-            
-            .run()
-    }
-    
+
+            .run()
+    }
+
     func testMultipleMiddlewarePost() {
         router.post("/userMultiMiddleware") { (middleware: UserMiddleware, middleware2: UserMiddleware2, middleware3: UserMiddleware3, user: User, respondWith: (User?, RequestError?) -> Void) in
             print("POST on /userMultiMiddleware for user \(user) - received headers \(middleware.header), \(middleware2.header), \(middleware3.header)")
             self.userStore[user.id] = user
             respondWith(user, nil)
         }
-        
+
         let user = User(id: 5, name: "Neil")
         let goodHeaders = ["TestHeader": "Foo", "TestHeader2": "Bar", "TestHeader3": "Baz"]
         let missing2ndHeader = ["TestHeader": "Foo", "TestHeader3": "Baz"]
         let missing3rdHeader = ["TestHeader": "Foo", "TestHeader2": "Bar"]
-        
+
         buildServerTest(router, timeout: 30)
             // Test that handler is invoked successfully when all middlewares are satisfied
             .request("post", path: "/userMultiMiddleware", data: user, headers: goodHeaders)
             .hasStatus(.created)
             .hasContentType(withPrefix: "application/json")
             .hasData(user)
-            
+
             // Test that Middleware2 fails when its header is missing, by examining the status (.notAcceptable)
             .request("post", path: "/userMultiMiddleware", data: user, headers: missing2ndHeader)
             .hasStatus(.notAcceptable)
             .hasNoData()
-            
+
             // Test that Middleware3 fails when its header is missing, by examining the status (.badRequest)
             .request("post", path: "/userMultiMiddleware", data: user, headers: missing3rdHeader)
             .hasStatus(.badRequest)
             .hasNoData()
-            
-            .run()
-    }
-    
+
+            .run()
+    }
+
     func testSingleMiddlewarePostIdentifier() {
         // Expected user: User(id: 1, name: "Andy")
         guard let user = userStore[1] else {
-            print("no value found for userStore[1]")
-            XCTFail()
+            XCTFail("no value found for userStore[1]")
             return
         }
-        
+
         router.post("/userMiddleware") { (middleware: UserMiddleware, user: User, respondWith: (Int?, User?, RequestError?) -> Void) in
             print("POST with identifier on /userMiddleware for user \(user) - received header \(middleware.header)")
             let id = 1
             self.userStore[id] = user
             respondWith(id, user, nil)
         }
-        
+
         buildServerTest(router, timeout: 30)
             .request("post", path: "/userMiddleware", data: user, headers: ["TestHeader": "Hello"])
             .hasStatus(.created)
             .hasContentType(withPrefix: "application/json")
             .hasData(user)
-            
+
             .request("post", path: "/userMiddleware", data: user)
             .hasStatus(.badRequest)
             .hasNoData()
-            
-            .run()
-    }
-    
+
+            .run()
+    }
+
     func testMultipleMiddlewarePostIdentifier() {
         // Expected user: User(id: 1, name: "Andy")
         guard let user = userStore[1] else {
-            print("no value found for userStore[1]")
-            XCTFail()
+            XCTFail("no value found for userStore[1]")
             return
         }
-        
+
         router.post("/userMultiMiddleware") { (middleware: UserMiddleware, middleware2: UserMiddleware2, middleware3: UserMiddleware3, user: User, respondWith: (Int?, User?, RequestError?) -> Void) in
             print("POST on /userMultiMiddleware for user \(user) - received headers \(middleware.header), \(middleware2.header), \(middleware3.header)")
             let id = 1
             self.userStore[id] = user
             respondWith(id, user, nil)
         }
-        
-        let goodHeaders = ["TestHeader": "Foo", "TestHeader2": "Bar", "TestHeader3": "Baz"]
-        let missing2ndHeader = ["TestHeader": "Foo", "TestHeader3": "Baz"]
-        let missing3rdHeader = ["TestHeader": "Foo", "TestHeader2": "Bar"]
-        
+
+        let goodHeaders = ["TestHeader": "Foo", "TestHeader2": "Bar", "TestHeader3": "Baz"]
+        let missing2ndHeader = ["TestHeader": "Foo", "TestHeader3": "Baz"]
+        let missing3rdHeader = ["TestHeader": "Foo", "TestHeader2": "Bar"]
+
         buildServerTest(router, timeout: 30)
             // Test that handler is invoked successfully when all middlewares are satisfied
             .request("post", path: "/userMultiMiddleware", data: user, headers: goodHeaders)
             .hasStatus(.created)
             .hasContentType(withPrefix: "application/json")
             .hasData(user)
-            
+
             // Test that Middleware2 fails when its header is missing, by examining the status (.notAcceptable)
             .request("post", path: "/userMultiMiddleware", data: user, headers: missing2ndHeader)
             .hasStatus(.notAcceptable)
             .hasNoData()
-            
+
             // Test that Middleware3 fails when its header is missing, by examining the status (.badRequest)
             .request("post", path: "/userMultiMiddleware", data: user, headers: missing3rdHeader)
             .hasStatus(.badRequest)
             .hasNoData()
-            
-            .run()
-    }
-    
+
+            .run()
+    }
+
     func testSingleMiddlewarePut() {
         let user = User(id: 1, name: "NewUser")
 

            .hasNoData()
            .has { _ in XCTAssertNil(self.userStore[1]) }

            
            // Test that Middleware2 fails when its header is missing, by examining the status (.notAcceptable)
            .request("delete", path: "/userMultiMiddleware/1", headers: missing2ndHeader)
            .hasStatus(.notAcceptable)
            .hasNoData()
            
            // Test that Middleware3 fails when its header is missing, by examining the status (.badRequest)
            .request("delete", path: "/userMultiMiddleware/1", headers: missing3rdHeader)
            .hasStatus(.badRequest)
            .hasNoData()
            
            .run()
    }
    
    func testSingleMiddlewareDeleteParameters() {
        
        router.delete("/userMiddleware") { (middleware: UserMiddleware, query: MyQuery, respondWith: (RequestError?) -> Void) in
            print("DELETE on /userMiddleware - received header \(middleware.header)")
            guard let _ = self.userStore.removeValue(forKey: query.id) else {
                respondWith(.notFound)
                return
            }
            respondWith(nil)
        }
        
        
        buildServerTest(router, timeout: 30)
            .request("delete", path: "/userMiddleware?id=1", headers: ["TestHeader": "Hello"])
            .hasStatus(.noContent)
            .hasNoData()
            .has { _ in XCTAssertNil(self.userStore[1]) }
            
            .request("delete", path: "/userMiddleware?id=1")
            .hasStatus(.badRequest)
            .hasNoData()
            
            .run()
    }
    
    func testMultipleMiddlewareDeleteParameters() {
        
        router.delete("/userMultiMiddleware") { (middleware: UserMiddleware, middleware2: UserMiddleware2, middleware3: UserMiddleware3, query: MyQuery,  respondWith: (RequestError?) -> Void) in
            print("DELETE on /userMultiMiddleware - received headers \(middleware.header), \(middleware2.header), \(middleware3.header)")
            guard let _ = self.userStore.removeValue(forKey: query.id) else {
                respondWith(.notFound)
                return
            }
            respondWith(nil)
        }
        
        let goodHeaders = ["TestHeader": "Foo", "TestHeader2": "Bar", "TestHeader3": "Baz"]
        let missing2ndHeader = ["TestHeader": "Foo", "TestHeader3": "Baz"]
        let missing3rdHeader = ["TestHeader": "Foo", "TestHeader2": "Bar"]
        
        buildServerTest(router, timeout: 30)
            // Test that handler is invoked successfully when all middlewares are satisfied
            .request("delete", path: "/userMultiMiddleware?id=1", headers: goodHeaders)
            .hasStatus(.noContent)
            .hasNoData()
            .has { _ in XCTAssertNil(self.userStore[1]) }
            
            
            // Test that Middleware2 fails when its header is missing, by examining the status (.notAcceptable)
            .request("delete", path: "/userMultiMiddleware?id=1", headers: missing2ndHeader)
            .hasStatus(.notAcceptable)
            .hasNoData()
            
            // Test that Middleware3 fails when its header is missing, by examining the status (.badRequest)
            .request("delete", path: "/userMultiMiddleware?id=1", headers: missing3rdHeader)
            .hasStatus(.badRequest)
            .hasNoData()
            
            .run()
    }
    
    func testSingleMiddlewarePost() {
        router.post("/userMiddleware") { (middleware: UserMiddleware, user: User, respondWith: (User?, RequestError?) -> Void) in
            print("POST on /userMiddleware for user \(user) - received header \(middleware.header)")

    struct UserMiddleware2: TestMiddleware2 {
        let header: String
    }

    // A user-defined structure that can be used in a TypeSafeMiddleware context
    struct UserMiddleware3: TestMiddleware3 {
        let header: String
    }

    func testSingleMiddlewareGetSingleton() {
        let user = User(id: 4, name: "Matt")

