a bunch of tests and reorganization