If you set z_min and z_max to the correct points it'll work.
Currently you are specifying them wrongly,
to the bb's 0 corner [z min] and 4 corner [z max]
Instead do something like this to set them to the y_max point
z_min: bounding_box.corner(3).transform(transformation.inverse)
and the corner point above it
z_max: bounding_box.corner(7).transform(transformation.inverse)