Wiring up RSpec test suite and a little refactoring