Updated tests.
Corrected how encoding is found.
Fixed coding style.