Ported tests from Bouncy Castle test suite