Add unit tests for selection position calculation.