More tests and fixes in security module