Add a monitor server module /w tests

Also refactor the tests code and use a lib module
for the common functions