clean up nasty implementation of event_by_value and state_by_value
Before the refactor, this was the behavior. This helps prevent "straggler" events delivered after the connection has been closed. The old implementation seems to have had slightly different event dispatch behavior (probably because it wasn't a thread popping off a queue, rather it was directly attached to guts of the C implementation).
I'm not sure this is the right answer, but I guess we'll see...
allows us to write a log-quieting block in tests to avoid logging the teardown code