Broke dependencies into /lib and added unit tests

I only restructured the code into 3 files and added tests. I also checked that everything still worked with the full project. 

Please check that everything is fine for Amazon S3.