ENH: Added proper handling of nans for numpy.lib.function_base.median
to close issue #585.

Also added unit test.