json api messaging work and refactoring to aid testing