Running the new beta, $onpoly() seems to be 100% correct!
The bad news is: $inpoly() is now causing false positives and giving me points that aren't within the mouse's polygon.
I noticed this as well when testing your script. However, as $inpoly() is now using the same math routine as $onpoly(), I assumed this was due to your script depending on the previous behaviour. Also, $inpoly() was working correctly in my tests.
I just compared $inpoly() and $onpoly() and it turns out that $onpoly() has some extra code that adjusts the provided polygon to prepare it for use eg. it extends the polygon if it is not completely closed. I have added this code to $inpoly() and am no longer seeing the yellow lines when running your script. This change will be in the next beta.