Moved permutation test to separate function.