Fix #1529
Bug fix
Updated tests
Merge pull request #1565 from sjinks/issue-1529

Fix #1529