This throws an error if custom_img_name is nil (as it is on my account). I'd suggest putting a check for nil in images.get and then also putting an if here to not test this if custom_img_name is nil (unless we can quickly create and delete an image in this test, that would work too).