Fix JParser to better respect ByteBuffer's position/limit.

Also includes some unit tests to verify the bug fix.