Fixes for IE7/8

Main issue was use of Array.indexOf(). This is not supported in IE7/8.
Provided shims for these browsers.

Also fixed sample tests to avoid using ES5 syntax (Array.forEach) so that these
sample tests will run and pass on IE7/8.