Separating logic so rspec can work.