fix HTML escaping in structured text
fix some of the tests, introduce test mocks