Refactor verifyHai and improve tests