Refactor code and run tests with auth