Fix issue #231 and add test.