BZ-991058: safe wrappers need to be serializable
(cherry picked from commit e18f90dd0519341ef8bb21d4a09664dc822b6479)