Fixed order of check execution and simplification in testgarbage.cpp