Add tests and update documentation