Created database does not appear in database list
You have two commands confused:


initdb is used once to initialize a DB environment directory structure. That does not create a new database.
createdb is used for each DB you want to create.


When you ran your initdb you were just initializing the folder /var/lib/pgsql/test to hold ALL future databases, but you did not actually create ANY database.


  initdb creates a new PostgreSQL database cluster. A database cluster is a collection of databases that are managed by a single server instance.


Reference: initdb (PostgreSQL Documentation)

You did not specify if this is a test machine or planned for prod, but you probably should use the service command to run the initdb and after that sudo to the postgres user to run the createdb. Often in *nix systems the installer setups up PGDATA variable for you so you don't have to specify the directory. There are some installers that even run the initdb for you; you did not specify the OS, so no idea of how your OS / installer handles setup/installation.

So, you may do something like:

sudo service postgresql initdb
sudo su - postgres
createdb test
psql -c "\l test"