Issue 1418: fix for incorrect median

A newline apparently caused the median to be calculated incorrectly (?????). Also separated part of it out into its own little method since set_results_statistics is fairly long.