Added tests and some documentation.