updated unit tests and cleaned up JS code.
Merge branch 'master' of github.com:pubnub/javascript