Make event handler registration synchronous

When spawning new event handlers, wait until they’ve received a valid
InputChannel before returning. Fixes a race in TestExchange.

Tidy comments and remove some compiler warnings.