fix the container tests

and fix a few bugs in container.c along the way.