bugfix for #5231 and extended main testing script