add test of R&D planning
and fix bugs exposed by test