More tests to check dynamic types.
Fixes #168.
Added backtracking tests related to issues #168, #171, #177.