Fix logic error on handling incoming server responses.
Refactor server JSON response helpers into own module.