Refactor p1, p2, and add tests for zero