Fix intermittent test failure

Submitting a task to the executor does not guarantee that it would be executed immediately. Sometimes the task might be still pending and the assert to check the completed task count might fail. Using the count of all the tasks ever scheduled will stop these intermittent failures.