tests, and small changes

Shamelessly copied tests from node-bencoding, changed code to work
against tests. Undid the global polyfil, made local instead