Fixed test that is broken in Java 1.8.

Fixed test that is broken in Java 1.8 due to being sensitive to the
iteration order of elements in a HashSet.