FLUID-5250: Based on FLUID-5251 with an extra testcase based on the example from FLUID-5250

Not sure whether this pull is relevant, or whether it should be discarded as a duplicate of the one already existing in https://github.com/fluid-project/infusion/pull/454 .. in any case, this pull request contains the one just mentioned... they only differ by the last commit https://github.com/kaspermarkus/infusion/commit/607088fac3f57cd91abd5f90065e1d63a1af35ed