Event with generic

Fix event handler crash bug
Change event class to generic class
Adding test case