Refactor and support setup/teardown cancel