added rspec coverage, bugs fixed