Wraps ioloop fetcher for unit tests in a function.

Otherwise, the ioloop instance is fetched in the main loop
but launched in a separate thread, which seems to cause problems.
Hopefully this fixes sporadic deadlocks in unit tests
Merge pull request #181 from spotify/freider/potential_deadlock_fix

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