refactoring: extracted methods; added test
(cherry-picked from e211118)
fixed apidoc