Added new test for median function.
Refactoring of sum, mean, and ds-range. Corrected median function.