Put scheduler-sensitive spawn test in a block

Makes it easier when testing at the REPL since the test relies
on us not yielding back to the scheduler before the call to `wait`.
Fix two uv assertion failures in certain situations

There are two closely related scenarios here. In the first one,
the remote closes the connection while we're issuing the shutdown
request, causing us to call uv_close. This causes libuv to call
the callback with UV__ECANCELED, but since we have already called
uv_close we'd get an assertion failure.

The second is pretty much the same situation, but with us calling
uv_close before uv_shutdown. There was an assertion in libuv that
was placed too early (i.e. before checking whether the stream had
already been closed and in that case returning an error code).
The corresponding libuv commit fixes that.