Improve tests to have tolerances
Improve rchisqcor to be more accurate
Clean up test code