         let expectation = self.expectationWithDescription("Update login")
         let updated = Login.createWithHostname("hostname1", username: "username1", password: "password3")
 
-        var usageData = updated as! LoginUsageData
-        usageData.timeCreated = NSDate.nowMicroseconds()
-        usageData.timeLastUsed = NSDate.nowMicroseconds()
-
-        addLogin(login)() >>>
+        addLogin(login) >>>
             updateLogin(updated) >>>
             getLoginsFor(login.protectionSpace, expected: [updated]) >>>
-            done(expectation)
+            done(login.protectionSpace, expectation: expectation)
 
         waitForExpectationsWithTimeout(10.0, handler: nil)
     }
 
-    /* XXX: Trying to get the usage data for a login throws EXC_BAD_ACCESS. Punting on this for now.
+    /*
     func testAddUseOfLogin() {
         let expectation = self.expectationWithDescription("Add visit")
 
-        login.timeCreated = NSDate.nowMicroseconds()
-        addLogin(login)() >>>
+        if var usageData = login as? LoginUsageData {
+            usageData.timeCreated = NSDate.nowMicroseconds()
+        }
+
+        addLogin(login) >>>
             addUseDelayed(login, time: 1) >>>
-            getLoginDetailsFor(login, expected: login) >>>
-            done(expectation)
+            getLoginDetailsFor(login, expected: login as! LoginUsageData) >>>
+            done(login.protectionSpace, expectation: expectation)
 
         waitForExpectationsWithTimeout(10.0, handler: nil)
     }
     */
 
-    func done(expectation: XCTestExpectation)() -> Success {
+    func done(protectionSpace: NSURLProtectionSpace, expectation: XCTestExpectation)() -> Success {
         return removeAllLogins() >>>
-            getLoginsFor(login.protectionSpace, expected: []) >>> {
+            getLoginsFor(protectionSpace, expected: []) >>> {
                 expectation.fulfill()
                 return succeed()
         }
     }
 
     // Note: These functions are all curried so that we pass arguments, but still chain them below
-    func addLogin(login: LoginData)() -> Success {
+    func addLogin(login: LoginData) -> Success {
         log.debug("Add \(login)")
         return logins.addLogin(login)
     }
 
-    func updateLogin(login: LoginData)() -> Success {
-        log.debug("Update \(login)")
-        var usage = login as! LoginUsageData
-        usage.timePasswordChanged = NSDate.nowMicroseconds()
-        return logins.updateLogin(login)
+    func addLoginCurried(login: LoginData) -> (() -> Success) {
+        return { return self.addLogin(login) }
     }
 
-    func addUseDelayed(login: Login, time: UInt32)() -> Success {
-        sleep(time)
-        login.timeLastUsed = NSDate.nowMicroseconds()
-        let res = logins.addUseOf(login)
-        sleep(time)
-        return res
+    func updateLogin(login: LoginData) -> (() -> Success) {
+        return {
+            log.debug("Update \(login)")
+            var usage = login as! LoginUsageData
+            usage.timePasswordChanged = NSDate.nowMicroseconds()
+            return self.logins.updateLogin(login)
+        }
     }
 
-    func getLoginsFor(protectionSpace: NSURLProtectionSpace, expected: [LoginData])() -> Success {
-        log.debug("Get logins for \(protectionSpace)")
-        return logins.getLoginsForProtectionSpace(login.protectionSpace) >>== { results in
-            XCTAssertEqual(expected.count, results.count)
-            for (index, login) in enumerate(expected) {
-                XCTAssertEqual(results[index]!.username!, login.username!)
-                XCTAssertEqual(results[index]!.hostname, login.hostname)
-                XCTAssertEqual(results[index]!.password, login.password)
+    func addUseDelayed(login: LoginData, time: UInt32) -> (() -> Success) {
+        return {
+            sleep(time)
+            if var usageData = login as? LoginUsageData {
+                usageData.timeLastUsed = NSDate.nowMicroseconds()
             }
-            return succeed()
+            let res = self.logins.addUseOf(login)
+            sleep(time)
+            return res
+        }
+    }
+
+    func getLoginsFor(protectionSpace: NSURLProtectionSpace, expected: [LoginData]) -> (() -> Success) {
+        return {
+            log.debug("Get logins for \(protectionSpace)")
+            return self.logins.getLoginsForProtectionSpace(protectionSpace) >>== { results in
+                XCTAssertEqual(expected.count, results.count)
+                for (index, login) in enumerate(expected) {
+                    XCTAssertEqual(results[index]!.username!, login.username!)
+                    XCTAssertEqual(results[index]!.hostname, login.hostname)
+                    XCTAssertEqual(results[index]!.password, login.password)
+                }
+                return succeed()
+            }
         }
     }
 
     /*
-    func getLoginDetailsFor(login: Login, expected: LoginUsageData)() -> Success {
-        log.debug("Get details for \(login)")
-        let deferred = logins.getUsageDataForLogin(login)
-        log.debug("Final result \(deferred)")
-        return deferred >>== { login in
-            log.debug("Got cursor")
-            XCTAssertEqual(expected.timePasswordChanged, login.timePasswordChanged)
-            XCTAssertEqual(expected.timeLastUsed, login.timeLastUsed)
-            XCTAssertEqual(expected.timeCreated, login.timeCreated)
-            return succeed()
+    func getLoginDetailsFor(login: LoginData, expected: LoginUsageData) -> (() -> Success) {
+        return {
+            log.debug("Get details for \(login)")
+            let deferred = self.logins.getUsageDataForLogin(login)
+            log.debug("Final result \(deferred)")
+            return deferred >>== { l in
+                log.debug("Got cursor")
+                XCTAssertLessThan(expected.timePasswordChanged - l.timePasswordChanged, 10)
+                XCTAssertLessThan(expected.timeLastUsed - l.timeLastUsed, 10)
+                XCTAssertLessThan(expected.timeCreated - l.timeCreated, 10)
+                return succeed()
+            }
         }
     }
     */
 
-    func removeLogin(login: LoginData)() -> Success {
-        log.debug("Remove \(login)")
-        return logins.removeLogin(login)
+    func removeLogin(login: LoginData) -> (() -> Success) {
+        return {
+            log.debug("Remove \(login)")
+            return self.logins.removeLogin(login)
+        }
     }
 
     func removeAllLogins() -> Success {
         log.debug("Remove All")
-        return logins.removeAll()
+        return self.logins.removeAll()
     }
 }
        let expectation = self.expectationWithDescription("Add login")
        let login2 = Login.createWithHostname("hostname1", username: "username2", password: "password2")

        addLogin(login)() >>>
            addLogin(login2) >>>
            getLoginsFor(login.protectionSpace, expected: [login2, login]) >>>
            done(expectation)

        waitForExpectationsWithTimeout(10.0, handler: nil)
    }

    }

    func testAddLogin() {
        log.debug("Created \(self.login)")
        let expectation = self.expectationWithDescription("Add login")

        addLogin(login) >>>
            getLoginsFor(login.protectionSpace, expected: [login]) >>>
            done(login.protectionSpace, expectation: expectation)

        waitForExpectationsWithTimeout(10.0, handler: nil)
    }
