Refactor and add test for companies.