Added checks for keep state before join. Some tests are reworked.