         XCTAssertEqual(token.generator.secret, NSData(bytes: kValidSecret, length: kValidSecret.count))
 
         // Save the token
-        let keychainItem = try keychain.addToken(token)
+        guard let keychainItem = try? keychain.addToken(token) else {
+            XCTFail("Failed to save token to keychain")
+            return
+        }
 
         // 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)
+        do {
+            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)
+        } catch {
+            XCTFail("Error thrown from keychain: \(error)")
+            return
+        }
 
         // Modify the token
         let modifiedToken = Token(name: "???", issuer: "!", generator: token.generator.successor())

    let keychain = Keychain.sharedInstance

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

        }

        // Fetch the token again
        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 {
