Some basic Service unit tests, minor fixes and refactoring