Fix handling of listeners being added and removed mid-dispatch

Before, having the last event listener remove itself (to implement
EventEmitter.prototype.once-like semantics) threw an exception. Fix this by
making a copy of the listener list on dispatch. While we're at it, mimic the
semantics of the real DOM EventTarget interface. Event listeners added
mid-dispatch do not run until the next one, however listeners removed, if they
have not yet run, will not run in the current one.

Also adds a unit test to test this behavior.
Implement DOM Level 3 behavior instead

Instead of having removeEventListener affect the current dispatchEvent, but not
addEventListener, have neither do it. This is DOM Level 3's behavior rather
than DOM Level 2's behavior.

As of writing, IE and older Opera matches the Level 3 behavior and other
browsers match the Level 2 behavior.  Mimic the IE behavior because it's
simpler and this is not a critical edge case. See
https://github.com/sockjs/sockjs-client/pull/127 for discussion.

Also revise the unit test to actually test the case when the listener list goes
empty which was the original goal of this entire exercise.
Merge pull request #127 from davidben/master

Fix handling of listeners added and removed mid-dispatch