Add tests and comments