[PATCH] Fixed tests for image handling, and cleaned up image parsing.