Fixes issues found by scrutinizer-ci
Improves tests for moveItem()
Improves implementation by reducing complexity