Removed API objects dependency on Service class and some cleanup.
Cleanup code and added unit tests