Added many new test cases to improve test coverage; other minor changes