Unit tests

bugfixes and new unit tests

we should add mocks so we can unit test the cdbs that are generated too