Bug Fixes

A couple of bug fixes and additional tests