Made main loop errors clearer, changed test function to real function.