Fix test failures and add doc.