Added a couple of tests and used as opp for some restructuring