Fixed run_tests function error handling

Change-Id: Ic899135d91b158dc43c5207cfdc0306724d9a986