test: fix out-of-scope handle in settergetter test

It's not legal to return a v8::Value from a function that has a
v8::HandleScope without wrapping it with v8::HandleScope::Close() first.

Without a call to v8::HandleScope::Close(), the handle gets zapped when
the scope object is destroyed.  That is, in debug builds; in release
builds the behavior is undefined and random.

Take the easy way out by dropping the scope object; the caller already
has one set up.
test: fix bad Local<T>::As<U>() casts

Don't cast to v8::Object when the value is expected to be a v8::String.
It works in release builds but triggers an assertion in debug builds.
The workaround is simple: just don't cast.
nan: don't call String::AsciiValue with non-ascii

Creating v8::String::AsciiValue objects from v8::String handles that
contain non-ASCII input triggers asserts in debug builds so don't do
that.

Use v8::String::Value instead, it flattens the string to a two-byte
encoding.  It may consume a bit more memory than v8::String::Utf8Value
but it works predictably when the input contains characters > 127
because the string length is never ambiguous: the length in characters
is the length in bytes.

While here, rewrite NanRawString() so it only creates the flattened
string object when it's really necessary, for BASE64 and HEX encodings.
Should speed up the common case significantly, especially for large
strings.
test: fix buffer overrun in settergetter test

NanFromV8String() doesn't zero terminate the result, use NanCString()
instead.  The test worked okay by accident in release builds but not
in debug builds.
Merge pull request #61 from bnoordhuis/test-fixes

Debug build fixes