Improved the test loop