Add tests and made some changes.