Add trapezoid tests and fix a bug