Reorganize and fix tests.