Rewrites the cli argument parser as a function and adds tests

I can't quite get the test right tho...