Fixed test issues with linker error. Minor refactoring.