Error handling and some extra test cases.