Add tests and fix uncovered bugs.

Do we want this to be a info log or a vlog?