SAMZA-224. Fix race condition in TestStatefulTask