Optimize assertions for better performance

Replaced assertions with php native functions or at least without chaining.