Improved ImageProvider code and added test