[QAE1030] Rspec coverage

* Small refactoring
* Some fixes
* Rspec tests
hmm, let me check