parser: Use the right length for parsing the stream contents

The ByteArray we use to buffer the contents of a stream in order to
pass them to the parser may have a bigger length. We should use the
cursor position that we use to put a '\0' in the buffer instead. We
could also use -1, but this saves us a strlen() later on.
tests: Add more checks to the parser stream unit
json-parser: use length parameter when validating utf-8

https://bugzilla.gnome.org/show_bug.cgi?id=727755