some refactoring for tests and mini updates