issue #1015 fix + fix broken tests