Change scope in register function for $app

When running unit tests, the register fails since $this is not in object context.

This change simply uses the $app variable that is passed, same result occurs, but unit testing is allowed to process