Fix #1820.
Fix #1824
Issue #1824: Add a test