Improved test coverage, refactoring the events listener