Refactor code * add more Rspec tests.