Added weighted median function and tests