More tests and small reorganization