more unit tests for REST controllers and small refactoring to enable unit testing