fix failing spec, refactor