taskschd/tests: Fix a use-after-free in scheduler tests.