util: Fix incorrect iteration over entries in InMemoryStorage

Change-Id: I975b1160570ccf6f1d9f46b0e04bc6f5d04b4675
Refs: #2301, #2149