Instantiate listener before registering events.
Instantiate listener before registering events.

This patch avoids a race condition that occurred in 2 out of 16 cases.

mrphs/torperf,meejah/torperf,mrphs/torperf,meejah/torperf,mrphs/torperf,meejah/torperf,meejah/torperf