Changed iteration over keys ot iteration over entries. Implemented unit test as part of this process.