Refactor readerTools.js

Includes fix for some failing JavaScript tests.
Also found the source of problem with word list (BL-599), but the fix is not included in this pull request.