tidy up specs and refactor classes