Refactor and reorganize tests.