Add tests and fix bug with multiple pools