fix singleton, refactor tests