Fix randomness in tests