Testing and clean up

* Added some tests
* Cleaned up the code
* Removed sdbwriter separate project