Added docs and a constant
Error handling and tests for TextEncoder