refactor controllers, tests