Add some unit tests and fix feedback