minor refactoring, adding tests for admin API