Re-introducing the reverted merge from joakim-hove/ert-test-run, with additional fixes from that branch