The test waits for the secondary to log the "dbCheckStop" entry, but that is not enough to guarantee that the primary has logged its entry. This is because health log entries are written asynchronously with replicating the oplog entries.
On slow machines, it could be possible to replicate the dbCheckStop oplog entry and have the secondary write to its healthlog before the primary.