Simplify codes.
Add test cases.