refactor sqldb: production and test can use different database settings.
revise unit test cases to support all operations
read port from environment variables