Added a JS unit test to check that an error is thrown when the protocol version is incorrect

#1531
Made changes as per code review feedback

#1531