refactor by extracting utility method from user and authentication test.