[1.4.x] Fixed #20906 -- Fixed a dependence on set-ordering in tests

Backport of 1ae64e96c1 from master