Release/bb refaktor

Added changes from Mark that include additional API tests and JS tests. Automatic merge failed so this PR is a manual merge from Mark's work.