Updated with unit tests
Removed if-name-main test stuff