add code for building, installing and running src/test/modules

Patch from Alvaro Herrera

This won't work with MSVC until we fix up src/tools/msvc.