Fixed weighted median algo, added a few test cases