added auth and tests
added debug flag