Rinse the beans, then soak in clean cold water overnight. Drain and rinse them in a colander, put into a large saucepan, cover with plenty of cold water and boil rapidly for 10 minutes, then simmer for a further 20-30 minutes until they are lightly cooked (still slightly hard in the middle and firm on the outside).
Peel and chop the onions, peel and crush the garlic. Chop the tomatoes if using fresh. Chop the fresh herbs.
Drain the beans through a colander and keep aside. In the same saucepan, heat the olive oil and fry the onions, garlic, oregano and thyme, until they start turning pale golden. Add the tomatoes with all the juice from the cans or, if fresh tomatoes are used, add 150 ml water. Then add the tomato puree and sugar, break up the mixture with a fork, season with salt and pepper, cover and simmer for 30 minutes or until the sauce thickens.
Preheat the oven to 180°C (350°F, Gas Mark 4)
Mix the parsley into the tomato sauce, add the beans and mix well. Spread the beans in an oven dish, season with salt and pepper then cook in the pre-heated oven for 30 minutes, without stirring. (Alternatively, add the beans to the tomato sauce, mix well, cover and simmer for 10-15 minutes).