File upload unit testing

These commits have been cherrypicked from @kedder. Thanks for the good work so far! :+1: