added documentation and tests