ed.py, test_ed.py: revise code for simplicity, readability