Moved logic for dealing with replies from controller to service layer and provided some test cases.