refactored and improved register function test