Rep 1087 functional test with Marek's commits

Replaces #1088 including further tests.