Refactored test and initialize