add more unit tests for entering/leaving