Better for error handling for JS initialisers

Add some basic error checking for the JS initialisers. Add init-spec to
the tests to ensure that these are tested.