Rearranged files for better testing. Added some tests.