The problem is in

void db_create_default_users(int setupUserOnly, const char *zDefaultUser)

It first checks for the default user in the database

it should check zDefaultUser first and if that is empty go for the
default user in the database