Add some unit tests and other small things