Refactored the code to extract all of the image functionality into a seperate file and started to wrap some tests around it