[client][managed][offline] merge pull request #338 and add unit tests