Fixes #178.
Added tests related to issues #178 and #182.