fix crash when clearing assignments twice

- do not try to clear assignments for machine that has no assignments.
- add a test so we don't break it in the future