Only allow valid input in random test