Fix a minor bug in @mcordingley's past commit for min, add unit test for this case