Fixed file transfer when dir doesn't exist

AND created unit test