Added tests and updated code to v8