Refactored IDService. Added some tests.