Tests for refactored authentication method