     public func updatePersistentToken(persistentToken: PersistentToken,
         withToken token: Token) throws -> PersistentToken
     {
-        guard let attributes = token.keychainAttributes else {
-            throw Error.TokenSerializationFailure
-        }
+        let attributes = try token.keychainAttributes()
         try updateKeychainItemForPersistentRef(persistentToken.identifier,
             withAttributes: attributes)
         return PersistentToken(token: token, identifier: persistentToken.identifier)

    /// - throws: A `Keychain.Error` if the token was not added successfully.
    /// - returns: The new persistent token.
    public func addToken(token: Token) throws -> PersistentToken {
        guard let attributes = token.keychainAttributes else {
            throw Error.TokenSerializationFailure
        }
        let persistentRef = try addKeychainItemWithAttributes(attributes)
        return PersistentToken(token: token, identifier: persistentRef)
    }

private let kOTPService = "me.mattrubin.onetimepassword.token"

private extension Token {
    private func keychainAttributes() throws -> [String: AnyObject] {
        guard let url = Token.URLSerializer.serialize(self),
            let data = url.absoluteString.dataUsingEncoding(NSUTF8StringEncoding) else {
                throw Keychain.Error.TokenSerializationFailure
        }
        return [
            kSecAttrGeneric as String:  data,
