Split logic into static library, tests