get into a semi-working state again - was in the middle of fixing this then must have forgotten
ugly merge - but tests makes sense now