Fixed test_main issues