Fix issue #341 (github).
Add test case for #341 (github).