Fix for issue #12, and test for it