fix authorization, implement new keychain, add tests