add simple connection pooling

also added tests for connection pooling and pty exhaustion.