Move code around for rspec tests