refactor to allow stand alone functional testing