Add documentation and fix failing assertion