Add set-spaces function, refactor tests