code refactorings which makes the code that uses Runtime mockable for tests.
Merge pull request #3909 from ahmetmircik/new/3.3.3/mockRuntime

Code refactoring related to heap based eviction