Refactor pawn validation; add comments and tests.