Add specs for loading image from urls.

Move some functions to shared file.