More tests, some refactors.