Fix a couple of before / after hook related bugs in test runner