add rspec and refactoring