Adds specs and refactoring