refactor(ccdaservice): extract and test safeTrim function (#6788)