Fix unicode encoding issue and add better unit test

Some unicode encoding logic from merging with upstream was the issue.

@stvstnfrd 
Because now it is tested here :)
https://github.com/Stanford-Online/edx-platform/pull/172/files#diff-2c82e4fbf2d66c60a6b0bcfaf06edc54R137