add unit test and fix the use of MEDIA_ROOT. fix bug for scenario before <=> without image, after<=>with image
fix pep8