#469: Fix for multi-target compilation

Fix is required for multi-target compilation. This is a regression after redesigning Target class. But an old behavior was incorrect anyway, as incorrect target information was supplied to dispatch module via g->target.

We also need to improve our testing to catch such things during testing.