Fix numerous type errors in the unit tests

Remove tinytest casts that were suppressing them.

Fix for #11825.
Fix unearthed problems in unit tests