Refactored Auth to avoid the problem in #929, added test case for CS-6705