* Fix a typo. * Extract similar code to generateEvent function. * Remove functions to use generateEvent in the switch. * Refactor tests.