Fixing the algorithm

Adding a failing unit tests, and then making the code work.  I tried to make the changes minimal.

2 main improvements:
 - Phase 2 was using the wrong polygons for the "contains point" test  (The contains point test also was broken)
 - Phase 3 was using the wrong direction (trying to correct for phase 2)