Added several unit and test cases.