consolidated functions and added fetchInvites from server on error

I made the changes discussed here https://github.com/tidepool-org/blip/pull/137#issuecomment-56340435. Ready for review @nicolashery