Refactoring and Testing

Refactored register.php to make its javascript more testable, updated
testing framework, updated tests.