Reorganised and started writing tests