Consolidate several similar blocks into methods, and add several more assertions to the tests.