Added check for incoming data and appropriate tests