Pass type to event handlers
Add basic tests