Added stats functions for median/quantiles + tests.