Fixed and added a few tests for weighted median algorithm