refactor and added unit tests for monitor notifications and get_monitor_events_by_state