fixes rspec and refactor