Improved scripts for service monitoring. Added unit test.