[QAE1030] Rspec coverage

* Small refactoring
* Some fixes
* Rspec tests