Add connection testing & retry logic to pool

Hi Gary,

I took your advice and have submitted this new pull request. Please let me know if this is acceptable. 

cheers,
Matthew