Connection test and close added