Fixed incorrect conditional on image conversion, added tests