I think the strategy of sampling and comparing points need to be more robust. Occasionally this test fails, and it might be because the world coordinates of the point being tested falls on multiple tiles, which is not taken into account in comparison.