Lots of refactoring to service and action style + added lots of testing

Signed-off-by: Niklas Ekman <niklas.ekman@gmail.com>