add more assertions to unit tests, clean up code, check triplet validity when going to next triplet, not when testing for match