Fix #1655
Fix #1655 and test
Merge pull request #1793 from YusiFan/issue-1655

Issue 1655