started writing tests and found numerous bugs (and squashed them)