Add unit test for callback on early postgresql disconnect

Test adapted by that provided by Jess Sheneberger in #534