Use IO#wait instead to fix test for Ruby 1.9