fixing regression issues; added a few tests
Merge branch 'pr/1398'