Large Refactor. Moving Library files to lib directory and creating some tests.