Main test loop refactored.
Tests restored: 1 - 4.