Write Extend function and Event object so all tests pass