Add unit tests and documentation