Wraps ioloop fetcher/launcher for unit tests in a function.

Previously, the ioloop instance was fetched from the main thread
but launched in a separate thread, which seems to cause problems.
Hopefully this fixes sporadic deadlocks in unit tests.