Added documentation and fixed unittest