Extract fetchAndStore
Tests and fixes for fetchAndStore