add regression test for issue 1876

Regression test for http://projects.scipy.org/scipy/ticket/1876
The issue has already been fixed in a recent commit: https://github.com/scipy/scipy/pull/460