Preliminary refactoring to allow some test coverage before changing behaviour

Line coverage is only 70% on this new extracted class, but I'm too lazy to add more. And I'm not very happy of the test cases, too much reliance on MBeans exposed by the running JVM. Still, better than nothing and ready for merge if a reviewer agrees ...

Additional commits on this same branch will probably follow, but again, I prefer small commits ...