changes and tests, see #1