Minor fixes to stabilize tests on my end. Few memory leaks. Little changes how hooks are handled on failure. And other changes to make tests pass cleanly.