Moving pure code out of Main and adding a test for it