Exit run-tests with correct error code

review7411002
(grafted from ec915931bf69a18cc004d208064e14d159276972)

--HG--
branch : 3.2
extra : source : ec915931bf69a18cc004d208064e14d159276972
'res' should be global in load_modules

issue4045
(grafted from d1bf8bffed36b177685d2fa29dbe3608f85b5a79)

--HG--
branch : 3.2
extra : source : d1bf8bffed36b177685d2fa29dbe3608f85b5a79