fix (and test) for issue 546
fixes infinite loop issue introduced by previous
Merge branch 'issue_546' into next