This issue is valid, I am showing a way on how we solve this issue in a modded environment such that this could be adjusted in vanilla too.
(This issue becomes previous obvious when looking at the switch case statement in the code)
Use a structure block to scan rails that are facing North-SOUTH. Then rotate the structure by 180 degrees.
No no, you misunderstood. This is not a feature request. Villagers and other entities pathing on the mainthread causes unbearable lag spikes in the game on a multiplayer server (1-2 villagers trying to get to a distant place could already be enough) -> this is a bug, this shouldn't happen.