Fix Entity#clear() and add to test to prevent regression