This should get you the URL structure you are looking for.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/user\.php
RewriteCond %{QUERY_STRING} username=([a-zA-Z0-9]*)
RewriteRule ^(.*)$ http://www.test.com/%1? [L
Based on that statement, I am going to guess you are using Joomla. If so, Joomla inserts the row id in the URL string for it's SEF urls. It then retrieves and uses that to return the appropriate content for the page. Changing only this id in the url will return a different row from the database, even without changing the rest of the URL.
You will likely have to change a sql query to use the "username" column rather than the "U_id" column to lookup the users information for the page.
If you not using Joomla, what platform are you using.