Rectangular selection performance optimization. Tests fix