unit-tests: Invoke all registered thread cleanup handlers on test failure