Refactor and clean up tests.