fix an x/z swap and add tests