Fix issue 48

This adds a test for and fixes the issue in GH-48.