Refactored code for better testability

I refactored the code a little bit to make it more testable. I extracted a class and some methods and properties.

We need somehow extract an Image class which will hold properties like file_size, type and so on.