Add importJSONData to api/db.js for import plugins

- Abstract out the common functionality from the existing
  import function.
- Refactor to remove circular ghost and api references so we can add
  unit tests.
- Add unit tests for getVersion() and importJSONData().