It appears to be the RAILS_ENV=test that was causing the problems