Position refactoring and tests