Implements user authentication and tests