Add tests and documentation