Cover replies by tests, fixed some bugs