More specs and refactoring