avoid saving twice an image already saved locally; add related tests