Fixed/added tests, added documentation.