Fix test cases, minor edits elsewhere