Issue #275: bugfix plus additional tests