Tidied up some tests and implementation in handler