Fixing bug that allowed adding the same item more than once. Also adding test.