event emitter and tests

adding in events and making some of the callbacks optional.