fix bugs exposed by latest tests
3 files changed