Fixed a bug when uploading empty file

Added tests for this bug