Random made once for calculation thread
Introduction of fixed random seed for test
format
Hide unnecessary code and random for sample permuting
Additional permutation random r fixes
Merge pull request #295 from Bonder-MJ/master

Fixed random if required