Improved input tolerance.
Refactored test.js.