Refactor HEAT tree test for error handling