filter out non-unicode codepoints and add test
minor pep8 fix