Minor code cleanups and a test