Refactored external connector out into separate factory and added unit tests