Implemented the firing of events and added tests.