Improve documentation and add tests