flesh out tests and fix a small bug