Extract into functions, allows testing.
Define test structure