Fixes issue #279
Also added an integration level test that confirms the fix.
Had made a separate dir for the integration level tests thinking that
the unit tests were distributed with the package. After realizing this
isn't so I dropped them into the `tests` dir.
Merge pull request #285 from atatsu/connection-close

Fixes issue #279