Improved documentation and tests