some refactoring and added test level