added tests for env attribute and optimize env