Refactored msgValidator.js to fix issues found in worker.js