Replaced conditional row creation/update with db_merge().
Added test that flags a node using different user accounts and checks flag counts.