Fix runloop related issue in test