Remove unneeded unittest2 compatibility import.
Stop using more deprecated test methods.
Fix unclosed file ResourceWarnings.
Check for bytes rather than str.
Use bytes literals instead of string literals.