added tests and documentation.