Improved monitor and added test cases