fix indexes for source and used items
update tests
add test with duplicated items