added getMedianValue function, plus test drivers

cleaned up some syntax and made variable names more descriptive.