Fix loading invalid XML

Add tests for invalid XML + invalid JSON.