refactored ch2 and 3 with classes, added rspec tests
refactored ch1,ch2 and ch3 with classes, added rspec tests