Fix associated positions calculation, with tests