Fixed connection bug.
Added invalid connection unit-tests.