Tidied up and added unit tests for new form loading functionality