added test code to build registration from sql