Fix keySet iterator behavior for MapFactory

Fix keySet iterator behavior for MapFactory