Improve runloop usage in tests