fixed the algorithm for scrambled tests