Set variable scope;  add rspec tests