Prevent file leaks in ConnectionInfo

Also made ConnectionInfo configurable and added a simple unit tests.

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>