Move code into a package
Fix unit tests