refactoring, and added set of unit tests that I have to make pass to support INSERT statements
tidying