Rich text unit tests

Plus a little tidying