added heartbeat, refactor continues
timeout loops added
creating client library
moving test client
closing loops