Improved documentation and added tests