Fix issue #199 and add a test.