Timed tests and fix for zero-sized file.

Started as the fix for Redmine [#6088](https://dev.cfengine.com/issues/6088), but also includes timed tests in order to make an acceptance test for the fix.

Best reviewed commit by commit.