Add unit, integration tests and cleanup