tests: Handle errors in subshels properly

Setting -e casused errors in subshels to kill them, but in many cases these
errors were not propagated to the main testing process. This commit sets up
a handler for errors encountered by bash which makes the test fail in such
cases.