Refactor some parts and improve tests by creating separate pools for each case.