Api refactor on test

PR for review - not ready for merge yet