BUG: gh-2496

Fix and test bug https://github.com/scipy/scipy/issues/2496 which was caused by buggy behavior for a keyword value that was not tested.