reorganize the code that generates random configurations for testing