issue #916 fixed + tests