refactors initialize and adds tests