Memoization and refactoring

Modified memoization code and made it testable
Small refactorings
Testing methods using enumerator reversal

Comparison of checking invariants by predicate execution and testing
  membership with enumerator