Refactor index.js and tests to fit `require, exports, module` definition...

... signature.

Finishing a1fdc93831e775b54ab7ebea4dc37321cfae3ad2.