Issue #1 Fix

This commit fixes #1 and adds several test cases to help detect future
regressions.