Catch parse errors

 * Added unit tests.
 * When a json file cannot be parsed, we return an error instead of throwing. (Fixes #1)