Fix gz/zip upload of files to test framework.

With test case to ensure they don't break again. Problem was due to a small switch of an if to an elif in 7114d15a6d22 which had been sort of masking over an older bug.

Thanks to Peter Cock for reporting the issue.
Merge next-stable.