Refactoring to support REST unit tests