Refactor for testing, add stubs for unit tests