Add unit tests and fix bugs