add spec tests
fix issues found when running spec tests

Fix-ups for bugs and inconsistencies found when
running the spec tests.