refactoring and code cleanup; removed unnec tests