Refactor

Move AuthenticationFailure up a level
Add bewit authentication function