Improve default upload directory handling and add test for image collection persistence.