Since the latitude to tile y formula is unstable near the limit latitude (85.05112877980659), the latitude was being clipped with a slightler smaller value than the limit (85.051129), but this didn't prevent that latitudes near it were assigned to incorrect tile y values.
To fix this, the clipping now occurs after computing the y. A clipping of the input latitude to -89, 89 is maintained to avoid the formula failing with a division by zero near or at latitude 90.
Since the latitude to tile y formula is unstable near the limit latitude (85.05112877980659), the latitude was being clipped with a slightler smaller value than the limit (85.051129), but this didn't prevent that latitudes near it were assigned to incorrect tile y values.
To fix this, the clipping now occurs after computing the y. A clipping of the input latitude to -89, 89 is maintained to avoid the formula failing with a division by zero near or at latitude 90.