Tidy up entity tests and fix UTF-8 encoding bug