As you say, this could do with tests...