Initial changes to start refactor Api to be unit testable