Add error handling, modify test and add documentation.