Reducing number of while loops to allow bot to be more responsive
Added unittests for bot connect method