Added optimizations to reduced unnecessary tests