refactor code for portability/testing and maintain current CI and unit tests