Add testing to the test_optimizer test
Fix critical bug which stopped the test script from doing anything useful