refactored test and code in various files