tests enhanced
minor fixes and refactorings