Added unit tests. Cleared and commented code