bugfixes and tests for #1119