Unit tests and fixing bugs.

Amended service classes to conform to the Singleton pattern. Added more test cases.