Fixed buffer checking

Reverted the buffer check to the way I had it before so it will work with couchdb's javascript engine (spidermonkey)