fixing #818, respecting #591, adding a test
Merge pull request #993 from ujifgc/master

Fixing #818