[bcl] Fix a race in a Task test. Fixes #20921.