Better detection of MAIN_TEST
Attr initialisation added
Errors are now shown in test output.
Globals are now always restored