Fix bug in isSecurityCodeValid, check typeof, and more tests.