BZ-1019268: some additional fixes in order to avoid double encoding/decoding pointed by neus
(cherry picked from commit 843cf62665be542a4d6e0c399cd6fa45f55ac5e0)