Added some new cases to derivation tests, simplified the code