Refactor & Jasmine testing attemp