         }
 
         // Fetch the token again
-        guard let thirdKeychainItem = try keychain.persistentTokenWithIdentifier(keychainItem.identifier) else {
-            XCTFail("Failed to recover persistent token with identifier: \(keychainItem.identifier)")
-            return
-        }
-        XCTAssertEqual(thirdKeychainItem.token, modifiedToken)
-        XCTAssertEqual(thirdKeychainItem.identifier, keychainItem.identifier)
+        do {
+            guard let thirdKeychainItem = try keychain.persistentTokenWithIdentifier(keychainItem.identifier) else {
+                XCTFail("Failed to recover persistent token with identifier: \(keychainItem.identifier)")
+                return
+            }
+            XCTAssertEqual(thirdKeychainItem.token, modifiedToken)
+            XCTAssertEqual(thirdKeychainItem.identifier, keychainItem.identifier)
+        } catch {
+            XCTFail("Error thrown from keychain: \(error)")
+            return
+        }
 
         // Remove the token
         do {

        XCTAssertEqual(token.generator.secret, NSData(bytes: kValidSecret, length: kValidSecret.count))

        // Save the token
        let keychainItem = try keychain.addToken(token)

        // Restore the token
        guard let secondKeychainItem = try keychain.persistentTokenWithIdentifier(keychainItem.identifier) else {
            XCTFail("Failed to recover persistent token with identifier: \(keychainItem.identifier)")
            return
        }
        XCTAssertEqual(secondKeychainItem.token, keychainItem.token)
        XCTAssertEqual(secondKeychainItem.identifier, keychainItem.identifier)

        // Modify the token
        let modifiedToken = Token(name: "???", issuer: "!", generator: token.generator.successor())

    let keychain = Keychain.sharedInstance

    func testTokenWithKeychainItemRef() {
        // Create a token
        guard let token = Token.URLSerializer.deserialize(kValidTokenURL) else {
            XCTFail("Failed to construct token from url")
