make perm_test code more concise