Added tests/fixed image upload files to retain file extension and moved functions to methods