Refactored and improved auth and auth tests