added rspec testing and modified class methods