fixing regression issues; added a few tests

Fixes #1397.