Fixed a bug in service registration and enhanced tests