Added tests and more documentation.