Fixed auth again, added tests