Extract test executor main loop code