Test engine & Test cases

This patch continues the work on the Test engine (which was started in the
previous one). It introduces several bugfixes and improvements to the
implementation of the test engine and also provides it with a test case.