Add some unit tests and documentation