Fix bag comparison in javascript tests

Review 1249 by @Tryneus
Closes #1983