Implemented auth
Refactored tests a little