Added more documentation and fixed tests.