moved logic to #processResponse and added tests