fixed the failing test for the previous refactoring
memoised a few values to improve performances