Tests for issue #646
Fix for issue #646