fix memoization bug; self-hosted tests