Add documentation and tests