Add a unit test for the reactor

Also, change a few APIs that were expecting Sockets, but only actually
depended on IoHandle, to take IoHandle. In general, only APIs that rely
on setsockopts or connection should require Sockets.