Splitting stuff out into methods so it should be easier to write unit tests. Started writing unit tests for ExecuteQueryHandler.