added auth header, refactored, added tests