fixed the clipping bug and added some new tests