adds rspec tests and bug fixes