A little refactoring, more tests/assertions.