fix stop condition in randomized selection
add test to produce median of an array