Validate array indices

Fix #4. Fix #5. Add json-patch-tests and fix all errors found, including validating array indices.