Fix non-deterministic tests