Some improvements

- Remove calls to array_merge
- Remove duplicate class names from the alias map
- Alignment fixes
Added a couple of tests

These tests prove the need of the patch. Without it, both assertions fail, meaning that the results are being retrieved from the cache and the new entities are not being fetched.