[BUG #6849] prune test case of side effects
[BUG #6849] merge classes only if necessary
[BUG #6849] add test case for merging of classes