I know this is test code, but `LIMIT 1` is your friend.

Or...

```
SELECT MAX(id) + 1 FROM $table
```