Refactor connection callback handling with toPromise converter
Minor test fixes