fix connection error and unit testing class