Fix issues and add test cases for new issues.