Use wilcoxon test instead of ranksums

Several other small refactorings. Thanks for the comments, @adykstra