Randomness test; fix bug where global var was used incorrectly