Use underscore functionality for itemsByKey. Fix tests