improved connection handling and added test login