Testall and packages test fixes

Various fixes to package testing and a few fixes to the test framework to make it better/easier to use in masterfiles. It's probably best to review this commit by commit.

Unfortunately this revealed a test failure that was previously wrongly passing. See https://cfengine.com/dev/issues/1535.