Improved tests, added documentation.