Preheat your oven to 350°F (175°C) with a rack placed in the middle. Lightly oil a casserole baking dish and set it aside.
Bring a large pot of salted water to a boil. Add the pasta and cook it for 10 minutes or until al dente. Drain and return the pasta back to the pot.
Meanwhile warm up oil in a large skillet. Add the onions, cook them for a few minutes over medium heat until the onions are tender. Add the zucchini and 1/2 teaspoon of salt. Cook, stirring occasionally, for about 20 minutes or until the zucchini is tender and falling apart. Allow some pieces to get brown.
Remove the skillet from heat and toss in the spinach. Keep stirring and folding the spinach until it wilts (the warmth of the zucchini will do this).
Lastly, make the white sauce. Melt butter in a medium saucepan set over medium heat. Whisk in the flour, to make a paste. Slowly pour in the very warm milk while whisking constantly to prevent lumps from forming. Season with fresh nutmeg, 1/2 teaspoon of salt and pepper and cook until the mixture thickens, but is still pourable, like a thick soup.
Reserve about 1/2 cup of the white sauce and pour the rest into the pot with the drained pasta. Stir to combine, then transfer the pasta to the prepared baking dish.
Sprinkle with parmesan. Top with the zucchini-spinach mix, as evenly as possible. Add dollops of reserved béchamel all over the top of the vegetables. Next, top with the mozzarella balls in an even pattern. Lastly, add dollops of basil pesto in between the mozzarella balls.
Bake for 20 minutes or until the mozzarella is melted. Remove from the oven and allow to rest for about 10 minutes, then serve, with fresh basil on top.