Reset packet state before handing control to user

The connection will be in an invalid state if the event handler
throws an exception.
Add test for connection state reset
Merge pull request #100 from adamvr/reset-packet-before-emit

Reset packet state before handing control to user