Little tweaks for unit testability of certain aspect of the core. Added unit tests