Updated the tests and organized the code