[tests] Avoid deprecated except syntax.
[tests] Make string encoding issues explicit.
[lit] Make string encoding issues explicit.
[lit] Explicitly convert dict items() result to a list.