Quick fix for issue 51. Moved upload, download logging logic into
shared method, added unit test.

Note: although it no longer fails when downloading an empty file, it
will log the empty warning twice...