added test
added threadsafety, and included a background thread to manage number of idle connections
commit