Tests for issue #365 and better fix for the issue.