Add singleton pattern and tests