Refactoring export code, adding tests, and starting to import code