Added comments and refactored tests.